package com.example.ice.coursetable;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import java.util.Random;


public class ShowActivity extends Activity {

    private Button button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.show);
        Intent intent=new Intent();
        TextView textView=(TextView) findViewById(R.id.showRandom);
        //舌尖 舌质 颜色
        String imgDescription= createImgDescription();
        textView.setText(imgDescription);
        initViews();
    }


    public static int createMinToMaxRandom(int min,int max){

        int randomNUm = (int)Math.floor(Math.random() * (max - min + 1)) + min;
        return randomNUm;
    }

    private void initViews() {
        button = (Button) findViewById(R.id.show_button);
        button.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {

                //startActivity(new Intent(getApplicationContext(), CameraActivity.class));

                // TODO Auto-generated method stub

                Intent intent=new Intent();

                //Intent可以在不同的应用程序的Activity发送数据

                intent.putExtra("testIntent", "Robin");

                intent.setClass(ShowActivity.this, CameraActivity.class);//从哪里跳到哪里

                ShowActivity.this.startActivity(intent);
            }
        });
    }

    public String createImgDescription(){
        Random random = new Random();
        random.setSeed(1111);
        // 舌尖 舌质 颜色
        String[] sheJianSheZhiColorArr = {"", "淡红", "淡", "红", "红绛", "淡晦(暗)"};
        int sheJianSheZhiColorNum = createMinToMaxRandom(1, 2);
        String sheJianSheZhiColor = "";
        int sheJianSheZhiColorRandomNum = 0;
        if(sheJianSheZhiColorNum == 1){
            sheJianSheZhiColorRandomNum = createMinToMaxRandom(1, 2);
            sheJianSheZhiColor = sheJianSheZhiColorArr[sheJianSheZhiColorRandomNum];
        }else{
            sheJianSheZhiColorRandomNum = createMinToMaxRandom(3, 5);
            sheJianSheZhiColor = sheJianSheZhiColorArr[sheJianSheZhiColorRandomNum];

        }


        //舌尖 舌质 形状
        String[] sheJianSheZhiShapeArr = {"正常", "裂纹", "溃破(溃疡)", "齿印(痕)", "芒刺(草莓)", "瘀点(斑)"};
        int sheJianSheZhiShapeNum = createMinToMaxRandom(1, 2);
        String sheJianSheZhiShape = "";
        int sheJianSheZhiShapeRandomNum = 0;
        if(sheJianSheZhiShapeNum == 1){
            sheJianSheZhiShapeRandomNum = createMinToMaxRandom(0, 1);
            sheJianSheZhiShape = sheJianSheZhiShapeArr[sheJianSheZhiShapeRandomNum];
        }else{
            sheJianSheZhiShapeRandomNum = createMinToMaxRandom(2, 5);
            sheJianSheZhiShape = sheJianSheZhiShapeArr[sheJianSheZhiShapeRandomNum];
        }

        //舌尖 舌苔 颜色
        String[] sheJianSheTaiColorArr = {"", "白", "黄", "淡黄", "黑"};
        String sheJianSheTaiColor = "";
        int sheJianSheTaiColorNum = createMinToMaxRandom(1, 2);
        int sheJianSheTaiColorRandomNum = 1;
        if(sheJianSheTaiColorNum == 1){
            sheJianSheTaiColor = sheJianSheTaiColorArr[1];
        }else{
            sheJianSheTaiColorRandomNum = createMinToMaxRandom(2, 4);
            sheJianSheTaiColor = sheJianSheTaiColorArr[sheJianSheTaiColorRandomNum];
        }

        //舌尖 舌苔 形质
        String[] sheJianSheTaiShapeArr = {"", "薄", "厚", "少", "剥落"};
        int sheJianSheTaiShapeNum = createMinToMaxRandom(1, 2);
        String sheJianSheTaiShape = "";
        int sheJianSheTaiShapeRandomNum = 1;
        if(sheJianSheTaiShapeNum == 1){
            sheJianSheTaiShape = sheJianSheTaiShapeArr[1];
        } else{
            sheJianSheTaiShapeRandomNum = createMinToMaxRandom(2, 4);
            sheJianSheTaiShape = sheJianSheTaiShapeArr[sheJianSheTaiShapeRandomNum];
        }


        //舌中 舌质 形状
        String[] sheZhongSheZhiShapeArr = {"正常", "裂纹", "裂沟"};
        String sheZhongSheZhiShape = "";
        int sheZhongSheZhiShapeNum = createMinToMaxRandom(1, 2);
        int sheZhongSheZhiShapeRandomNum = 0;
        if(sheZhongSheZhiShapeNum == 1){
            sheZhongSheZhiShape = sheZhongSheZhiShapeArr[0];
        } else {
            sheZhongSheZhiShapeRandomNum = createMinToMaxRandom(1, 2);
            sheZhongSheZhiShape = sheZhongSheZhiShapeArr[sheZhongSheZhiShapeRandomNum];
        }

        //舌中 舌苔 颜色
        String[] sheZhongSheTaiColorArr = {"", "白", "黄", "淡黄", "黑"};
        String sheZhongSheTaiColor = "";
        int sheZhongSheTaiColorNum = createMinToMaxRandom(1, 2);
        int sheZhongSheTaiColorRandomNum = 1;
        if(sheZhongSheTaiColorNum == 1){
            sheZhongSheTaiColor = sheZhongSheTaiColorArr[1];
        } else{
            sheZhongSheTaiColorRandomNum = createMinToMaxRandom(2, 4);
            sheZhongSheTaiColor = sheZhongSheTaiColorArr[sheZhongSheTaiColorRandomNum];
        }

        //舌中 舌苔 形质
        String[] sheZhongSheTaiShapeArr = {"", "薄", "厚", "腻", "滑", "燥", "少", "剥落", "腻厚"};
        String sheZhongSheTaiShape = "";
        int sheZhongSheTaiShapeNum = createMinToMaxRandom(1, 2);
        int sheZhongSheTaiShapeRandomNum = 0;
        if(sheZhongSheTaiShapeNum == 1){
            sheZhongSheTaiShapeRandomNum = createMinToMaxRandom(1, 3);
            sheZhongSheTaiShape = sheZhongSheTaiShapeArr[sheZhongSheTaiShapeRandomNum];
        }else{
            sheZhongSheTaiShapeRandomNum = createMinToMaxRandom(4, 8);
            sheZhongSheTaiShape = sheZhongSheTaiShapeArr[sheZhongSheTaiShapeRandomNum];
        }

        // 舌侧 舌质 颜色
        String[] sheCeSheZhiColorArr = {"", "淡红", "淡白", "淡暗", "紫", "紫"};
        String sheCeSheZhiColor = "";
        int sheCeSheZhiColorNum = createMinToMaxRandom(1, 2);
        int sheCeSheZhiColorRandomNum = 0;
        if (sheCeSheZhiColorNum == 1){
            sheCeSheZhiColorRandomNum = createMinToMaxRandom(1, 2);
            sheCeSheZhiColor = sheCeSheZhiColorArr[sheCeSheZhiColorRandomNum];
        } else {
            sheCeSheZhiColorRandomNum = createMinToMaxRandom(3, 5);
            sheCeSheZhiColor = sheCeSheZhiColorArr[sheCeSheZhiColorRandomNum];
        }


        //舌侧 舌质 形状
        String[] sheCeSheZhiShapeArr = {"", "正常", "溃破", "齿印", "瘀点", "瘀斑"};
        String sheCeSheZhiShape = "";
        int sheCeSheZhiShapeNum = createMinToMaxRandom(1, 2);
        int sheCeSheZhiShapeRandomNum = 0;
        if (sheCeSheZhiShapeNum == 1){
            sheCeSheZhiShape = sheCeSheZhiShapeArr[0];
        } else {
            sheCeSheZhiShapeRandomNum = createMinToMaxRandom(1, 4);
            sheCeSheZhiShape = sheCeSheZhiShapeArr[sheCeSheZhiShapeRandomNum];
        }

        //舌侧 舌苔 颜色
        String[] sheCeSheTaiColorArr = {"", "白", "黄", "淡黄", "黑"};
        String sheCeSheTaiColor = "";
        int sheCeSheTaiColorNum = createMinToMaxRandom(1, 2);
        int sheCeSheTaiColorRandomNum = 1;
        if(sheCeSheTaiColorNum == 1){
            sheCeSheTaiColor = sheCeSheTaiColorArr[1];
        } else {
            sheCeSheTaiColorRandomNum = createMinToMaxRandom(2, 4);
            sheCeSheTaiColor = sheCeSheTaiColorArr[sheCeSheTaiColorRandomNum];
        }


        // 舌侧 舌苔 形状
        String[] sheCeSheTaiShapeArr = {"", "薄", "厚", "腻", "剥落", "唾液线", "腻厚"};
        String sheCeSheTaiShape = "";
        int sheCeSheTaiShapeNum = createMinToMaxRandom(1, 2);
        int sheCeSheTaiShapeRandomNum = 0;
        if (sheCeSheTaiShapeNum == 1){
            sheCeSheTaiShapeRandomNum = createMinToMaxRandom(1, 2);
            sheCeSheTaiShape = sheCeSheTaiShapeArr[sheCeSheTaiShapeRandomNum];
        }else{
            sheCeSheTaiShapeRandomNum = createMinToMaxRandom(3, 6);
            sheCeSheTaiShape = sheCeSheTaiShapeArr[sheCeSheTaiShapeRandomNum];
        }


        //舌跟 舌苔 颜色
        String[] sheGenSheTaiColorArr = {"", "白", "黄", "淡黄", "黑"};
        String sheGenSheTaiColor = "";
        int sheGenSheTaiColorNum = createMinToMaxRandom(1, 2);
        int sheGenSheTaiColorRandomNum = 1;
        if (sheGenSheTaiColorNum == 1){
            sheGenSheTaiColor = sheGenSheTaiColorArr[1];
        } else {
            sheGenSheTaiColorRandomNum = createMinToMaxRandom(2, 4);
            sheGenSheTaiColor = sheGenSheTaiColorArr[sheGenSheTaiColorRandomNum];
        }


        //舌跟 舌苔 形质
        String[] sheGenSheTaiShapeArr = {"", "薄", "厚", "腻", "少", "剥落", "腻厚"};
        String sheGenSheTaiShape = "";
        int sheGenSheTaiShapeNum = createMinToMaxRandom(1, 2);
        int sheGenSheTaiShapeRandomNum = 0;
        if(sheGenSheTaiShapeNum == 1){
            sheGenSheTaiShapeRandomNum = createMinToMaxRandom(1, 2);
            sheGenSheTaiShape = sheGenSheTaiShapeArr[sheGenSheTaiShapeRandomNum];
        }else{
            sheGenSheTaiShapeRandomNum = createMinToMaxRandom(3, 6);
            sheGenSheTaiShape = sheGenSheTaiShapeArr[sheGenSheTaiShapeRandomNum];
        }

        String description = "\n[舌尖]:舌质颜色"+sheJianSheZhiColor+", 舌质形状"+sheJianSheZhiShape+", 舌苔颜色"+sheJianSheTaiColor+",舌苔形质"+sheJianSheTaiShape+"; \n[舌中]:舌质形状"+sheZhongSheZhiShape+", 舌苔颜色"+sheZhongSheTaiColor+", 舌苔形质" +
        sheZhongSheTaiShape + "; \n[舌侧]:舌质颜色"+sheCeSheZhiColor+", 舌质形状"+sheCeSheZhiShape+", 舌苔颜色"+sheCeSheTaiColor +
        ", 舌苔形质"+sheCeSheTaiShape + "; \n[舌根]:舌苔颜色" +
        sheGenSheTaiColor+", 舌苔形质"+sheGenSheTaiShape+"\n";
        return description;
    }

}
